<?php
    include_once "ModelACTION.php";

    class ClienteAction extends ModelAction {

        public function ClienteAction(){
            /*
            if (!isset($_SESSION)){
                session_start();
            }*/

            $DAOf = DAOFactory::getInstancia();
            $objClienteDAO = $DAOf->getClienteDAO();
            
            parent::__construct($objClienteDAO);
            
        }

        public function obterPorId($value){

            if(is_object($value)){
                if($value instanceof Cliente){
                    if($value->getId() != null){
                        $objeto = parent::obterPorId($value);
                    }
                }
            } else {
                $VOBf = VOBFactory::getInstancia();
                $objCliente = $VOBf->getCliente();
                $objCliente->setId($value);
                
                $objeto = parent::obterPorId($objCliente);
            }

            return $objeto;
        }
       
        /*
         * ClienteAction::validarSalvar
         */
        private function validarSalvar(Cliente $objCliente){
            return true;
        }

        public function salvar(Cliente $objCliente){

            if($this->validarSalvar($objCliente)){
                return parent::salvar($objCliente);
            }           
            
        }

        public function deletar(Cliente $objCliente){
            return parent::deletar($objCliente);
        }

        

        public function  obterSoma(array $coluns, $colunSoma, $where = "") {

            $VOBf = VOBFactory::getInstancia();
            $objCliente = $VOBf->getCliente();
            
            return parent::obterSoma($objCliente, $coluns, $colunSoma, $where);
            
        }
        
    }

?>
